SP - Create a Physical Data Services from Relational Tables and Views
This page last changed on May 05, 2008.
Oracle Data Service Integrator Documentation > Data Services Developer's Guide How To Create a Physical Data Service from a Java Function
You can create physical data services based on custom Java functions that return both simple and complex types.
TopicsSetting Up the Physical Data Service Creation WizardPhysical data services are created using a wizard. Physical Data Service Creation WizardStarting the WizardTo start the physical data service creation wizard:
Creating a New Physical Data ServiceAccessing Java FunctionsAfter you choose Java Function as your data source, you need to specify a class name containing the Java functions.
Choosing Java Function as a Data SourceChoosing the Java class:To choose the Java class containing the Java functions:
Open Java Class DialogSelecting Java Functions to ImportAfter you select Java Function as your data source, you need to select the Java functions to import. Selecting Java Function DialogTo select the Java functions to import:
Setting Characteristics of Imported Java FunctionsAfter choosing the Java functions to import, you can optionally set the characteristics of the functions.
Setting Characteristics of Imported Java FunctionsThe following table describes the available options for each function you have selected to import. Options Available for Imported Java Functions
To set the characteristics of imported Java functions:
Setting the Physical Data Service NameYou can set the name of your data service to any legal name that does not conflict with another name in the current dataspace. To complete the wizard:
Oracle Data Service Integrator creates a pragma (visible in Source view) that defines the function signature and relevant schema type for complex types such as schema elements or SDO types. If there are existing data services in your project, you have the option of adding functions and procedures to that library or creating a new library for them. All the Java file functions are located in the same data service.
See AlsoConceptsHow Tos
Oracle Data Service Integrator Documentation > Data Services Developer's Guide Physical Data Services from Java Functions OverviewIn Oracle Data Service Integrator, you can create physical data services based on user-defined functions implemented as Java classes. Oracle Data Service Integrator supports Java functions returning the following types:
Oracle Data Service Integrator packages operations marked as create, update, or delete functions in an Entity data service. Otherwise, the resulting data service is of type Library. Functions determined to return void are automatically marked as library procedures. When creating a new physical data service, you can change the nominated function type. The Java method name, when used in an XQuery, becomes the XQuery function name qualified with a namespace.
Simple Java Types and Their XQuery CounterpartsThe following outlines the mapping between simple Java types and the corresponding XQuery or schema types:
Java functions can consume parameters and return values of the following types:
Physical Data Service from a Java Function - Example CodeThis topic provides examples showing the use of imported Java functions in an XQuery and the processing of complex types. Using a Function Returning an Array of Java PrimitivesAs an example, the Java function getRunningTotal can be defined as follows: public static float[] getRunningTotal(float[] list) { if (null == list || 1 >= list.length) return list; for (int i = 1; i < list.length; i++) { list[i] = list[i-1] + list[i]; } return list; } The corresponding XQuery for executing the above function is as follows: Declare namespace f1="ld:javaFunc/float"
Let $y := (2.0, 4.0, 6.0, 8.0, 10.0)
Let $x := f1:getRunningTotal($y)
Return $x
The results of the query is as follows: 2.0, 6.0, 12.0, 20.0, 30.0 Processing complex types represented via XMLBeansConsider a schema called Customer (customer.xsd), as shown in the following: <?xml version="1.0" encoding="UTF-8" ?> <xs:schema targetNamespace="ld:xml/cust:/BEA_BB10000" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="CUSTOMER"> <xs:complexType> <xs:sequence> <xs:element name="FIRST_NAME" type="xs:string" minOccurs="1"/> <xs:element name="LAST_NAME" type="xs:string" minOccurs="1"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> You could compile the schema using XMLBeans to generate a Java class corresponding to the types in the schema. xml.cust.beaBB10000.CUSTOMERDocument.CUSTOMER
Following this, you can use the CUSTOMER element as shown in the following: public static xml.cust.beaBB10000.CUSTOMERDocument.CUSTOMER[] getCustomerListGivenCustomerList(xml.cust.beaBB10000.CUSTOMERDocument.CUSTOMER[] ipListOfCust) throws XmlException { xml.cust.beaBB10000.CUSTOMERDocument.CUSTOMER [] mylocalver = pListOfCust; return mylocalver; } The resulting metadata information produced by the New Physical Data Service wizard will be: (::pragma function <f:function xmlns:f="urn:annotations.ld.oracle.com" kind="datasource" access="public"> <params> <param nativeType="[Lxml.cust.beaBB10000.CUSTOMERDocument$CUSTOMER;"/> </params> </f:function>::) declare function f1:getCustomerListGivenCustomerList($x1 as element(t1:CUSTOMER)*) as element(t1:CUSTOMER)* external; The corresponding XQuery for executing the above function is: declare namespace f1 = "ld:javaFunc/CUSTOMER"; let $z := ( validate(<n:CUSTOMER xmlns:n="ld:xml/cust:/BEA_BB10000"><FIRST_NAME>John2</FIRST_NAME><LAST_NAME>Smith2</LAST_NAME> </n:CUSTOMER>), validate(<n:CUSTOMER xmlns:n="ld:xml/cust:/BEA_BB10000"><FIRST_NAME>John2</FIRST_NAME><LAST_NAME>Smith2</LAST_NAME> </n:CUSTOMER>), validate(<n:CUSTOMER xmlns:n="ld:xml/cust:/BEA_BB10000"><FIRST_NAME>John2</FIRST_NAME><LAST_NAME>Smith2</LAST_NAME> </n:CUSTOMER>), validate(<n:CUSTOMER xmlns:n="ld:xml/cust:/BEA_BB10000"><FIRST_NAME>John2</FIRST_NAME><LAST_NAME>Smith2</LAST_NAME> </n:CUSTOMER>)) for $zz in $z return See AlsoHow Tos
Oracle Data Service Integrator Documentation > Data Services Developer's Guide Preparing to Create Physical Data Services From Java FunctionsThis topic provides an overview of how to create a new physical data service from Java functions. Before you can create physical data services based on custom Java functions, you need to create a Java class containing both the schema and function information. The entire process involves the following:
See AlsoConceptsHow TosOracle Data Service Integrator Documentation > Data Services Developer's Guide Creating XMLBean Support for Java FunctionsBefore you can create a Physical Data Service from Java functions, you need to create a .class file that contains XMLBean classes based on global elements and compiled versions of your Java functions. This topic describes how to create XMLBean classes based on a schema of your data. Supported XMLBean StandardsImported Java functions containing complex types must have a schema that conforms to one of the following XMLBean standards:
If your Java routines were compiled under previous versions, they will need to be recompiled before they can be imported.
Creating XMLBean Classes for Java FunctionsThis topic describes how to create XMLBean classes based on a schema of your data. Creating a New ProjectYou need to create a new project to build the XMLBean classes. New ProjectTo create a new project:
New Java Project WizardEnabling XMLBeans BuilderYou need to enable the XMLBeans Builder in the project to allow it to create classes based on the Java source and XML schema files. Project PropertiesTo enable XMLBeans Builder:
Enabling XMLBeans BuilderImporting Schema and Java Source FilesYou need to import the schema files and Java source files into the project. To import the schema and Java source files:
Creating a Project ReferenceThe final step involves creating a reference to your XMLBeans-based project from the dataspace in which you want to use the Java functions. To create the project reference:
When your project is deployed, Oracle Data Service Integrator does the following:
Project ReferencesSee AlsoHow TosReference |
![]() |
Document generated by Confluence on Jan 13, 2009 15:57 |